package com.godyao.mall.user.boot.controller;

import com.godyao.mall.core.model.ResultMsg;
import com.godyao.mall.user.boot.service.ISysUserService;
import com.godyao.mall.user.common.model.SysRole;
import com.godyao.mall.user.common.model.SysUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author godyao
 * @date 2022/4/2
 */
@RestController
@RequestMapping(value = "/user")
public class SysUserController {
    @Autowired
    public ISysUserService sysUserService;

    @GetMapping("/getByUsername")
    public ResultMsg<SysUser> getByUsername(String username){
        return ResultMsg.resultSuccess(sysUserService.getUserByUsername(username));
    }

    @GetMapping("/getRolesByUserId")
    public ResultMsg<List<SysRole>> getRolesByUserId(Long userId){
        return ResultMsg.resultSuccess(sysUserService.getRolesByUserId(userId));
    }

    @GetMapping("/getByUserId")
    public ResultMsg<SysUser> getByUserId(String userId){
        return ResultMsg.resultSuccess(sysUserService.getByUserId(userId));
    }

    @GetMapping("/listByUserId")
    public ResultMsg<List<SysUser>> listByUserId(@RequestBody List<String> userIds){
        return ResultMsg.resultSuccess(sysUserService.listByUserId(userIds));
    }

}
